import Vue from 'vue'
import VueRouter from 'vue-router'
Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    name: 'Login',
    component: () => import('@/views/login/')
  },
  {
    path: '/home',
    name: 'Home',
    component: () => import('../views/Home/'),
    children: [
      {
        path: '/setting',
        name: 'Setting',
        component: () => import('../views/Setting/'),
        children: [
          {
            path: '/',
            redirect: '/user'
          },
          {
            path: '/user',
            name: 'user',
            component: () => import('../views/user/'),
          }
        ]
      },
      {
        path: '/team',
        name: 'team',
        component: () => import('../views/Team/'),
      },
      {
        path: '/project',
        name: 'project',
        component: () => import('../views/project/'),
        children: [
          {
            path: '/',
            redirect: '/myproject'
          },
          {
            path: '/myproject',
            name: 'myproject',
            component: () => import('../views/project/myproject'),
          }
        ]
      }
    ]
  }
]


const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push (location) {
  return originalPush.call(this, location).catch(err => err)
}

const router = new VueRouter({
  routes
})

export default router
